import { ZoomAction, ZoomActionTypes } from '../actions/zoom.action';

export interface ZoomState {
    state: number,
    increment: boolean,
    decrement: boolean
}

export const initialZoomState: ZoomState = {
    state: 0,
    increment: false,
    decrement: false
};

export function ZoomReducer(state: ZoomState = initialZoomState, action: ZoomAction): ZoomState {
    switch(action.type) {
        case ZoomActionTypes.ZOOM_DECREMENT: {
            return {
                ...state,
                state: state.state - 1,
                increment: false,
                decrement: true
            }
        }
        case ZoomActionTypes.ZOOM_INCREMENT: {
            return {
                ...state,
                state: state.state + 1,
                increment: true,
                decrement: false
            }
        }
        default: {
            return state;
        }
    }
}